(function () {
    'use strict';

    angular
        .module('logcenterApp')
        .service('logmanagerService',logmanagerService);

    logmanagerService.$inject=['$http','$q'];
    function logmanagerService($http,$q) {

        var findSlowSvc = function (partition,startTime,endTime,time,code) {
            var deferred=$q.defer();
            $http.get('api/logmanager/slowService?partition=' + partition+"&startTime="+startTime
                + '&endTime='+ endTime + '&time=' + time+"&code="+code).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var findSvc = function (svc) {
            var deferred=$q.defer();
            $http.get('api/logmanager/findSvc?svc='+svc).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var findSlowSql = function (startTime,endTime,partition,svc,code) {
            var deferred=$q.defer();
            $http.get('api/logmanager/slowSql?startTime='+startTime + '&endTime='+ endTime + '&partition=' + partition+ '&svc=' + svc+"&code="+code).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        return {

            findSlowSvc:findSlowSvc,
            findSvc:findSvc,
            findSlowSql:findSlowSql

        };
    }
})();
